<?php

declare(strict_types=1);


namespace App\CustHub\Controller;

use App\Common\Constants\ErrorCode;
use App\Common\Helpers\SortHelper;
use App\CustHub\Annotation\ApiAuth;
use App\CustHub\Annotation\ChPermission;
use App\CustHub\Annotation\VerifySignature;
use App\CustHub\Constants\CrowSendingConstants;
use App\CustHub\Constants\SendConfigConstants;
use App\CustHub\Model\ChCrowdInvite;
use App\CustHub\Model\ChCrowdInviteLog;

use App\CustHub\Model\ChCrowdInviteSubTask;

use App\CustHub\Request\RoomKeywordRequest;
use App\CustHub\Service\ChContactService;
use App\CustHub\Service\ChListenContactRoomService;
use App\CustHub\Service\ChListenContactService;
use App\CustHub\Service\ChListenRoomService;
use App\CustHub\Service\ChSendConfigService;
use App\CustHub\Service\ChSopService;
use App\CustHub\Service\CrowdInviteService;

use App\CustHub\Service\StatisticsService;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\PostMapping;
use Hyperf\Di\Annotation\Inject;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Http\Message\ResponseInterface;

#[Controller(prefix: 'ch/statistics'),ApiAuth,VerifySignature]
class StatisticsController extends BaseController
{

    #[Inject]
    protected StatisticsService $service;

    #[Inject]
    protected ChListenRoomService $roomListenService;

    #[Inject]
    protected ChListenContactService $contactListenService;

    #[Inject]
    protected ChListenContactRoomService $chListenContactRoomService;

    #[Inject]
    protected ChSopService $sopService;

    public array $noNeedLogin = [];
    public array $noNeedVerifySign = [];


    #[PostMapping('getListenContactRoomListByday'),ChPermission('ch:statistics:getListenContactRoomList')]
    public function getListenContactRoomListByday()
    {
        $result = $this->chListenContactRoomService->getListenContactList($this->request->all());
        return $this->success($result);
    }

    #[PostMapping('getListenContactRoomList'),ChPermission('ch:statistics:getListenContactRoomList')]
    public function getListenContactRoomList()
    {
        $result = $this->chListenContactRoomService->getListenContactList($this->request->all());
        return $this->success($result);
    }

    #[PostMapping('delContactRoom'),ChPermission('ch:statistics:delContactRoom')]
    public function delContactRoom()
    {
        return $this->contactListenService->deleteListen($this->request->all())? $this->success('操作成功') : $this->error('操作失败');
    }

    #[PostMapping('addContactRoom'),ChPermission('ch:statistics:addContactRoom')]
    public function addContactRoom()
    {
        $result = $this->chListenContactRoomService->addListenContact($this->request->all());
        return $result? $this->success('操作成功') : $this->error('操作失败');
    }

    #[PostMapping('indexRoomChartData'),ChPermission('ch:statistics:indexRoomChartData')]
    public function indexRoomChartData()
    {
        return $this->success($this->service->indexRoomChartData($this->request->all()));
    }
    #[PostMapping('indexRoomData'),ChPermission('ch:statistics:indexRoomData')]
    public function indexDataRoom()
    {
        return $this->success($this->service->indexRoomData($this->request->all()));
    }
    #[PostMapping('getUpdateLog'),ChPermission('ch:statistics:getUpdateLog')]
    public function getUpdateLog()
    {
        return $this->success($this->service->getUpdateLog($this->request->all()));
    }

    #[PostMapping('indexChartData'),ChPermission('ch:statistics:indexChartData')]
    public function indexChartData()
    {
        return $this->success($this->service->indexChartData($this->request->all()));
    }
    #[PostMapping('indexData'),ChPermission('ch:statistics:indexData')]
    public function indexData()
    {
        return $this->success($this->service->indexDataCustom($this->request->all()));
    }

    #[PostMapping('robotStatistics'),ChPermission('ch:statistics:robotStatistics')]
    public function robotStatistics()
    {
        return $this->success($this->service->robotStatistics($this->request->all()));
    }
    #[PostMapping('chatStatisticsByDay'),ChPermission('ch:statistics:chatStatisticsByDay')]
    public function chatStatisticsByDay()
    {
        return $this->success($this->service->chatStatisticsByDay($this->request->all()));
    }
    #[PostMapping('getChatStatistics'),ChPermission('ch:statistics:getChatStatistics')]
    public function getChatStatistics()
    {
        return $this->success($this->service->getChatStatistics($this->request->all()));
    }
    #[PostMapping('getChatReplyStatisticsByDay'),ChPermission('ch:statistics:getChatReplyStatisticsByDay')]
    public function getChatReplyStatisticsByDay()
    {
        return $this->success($this->service->getChatReplyStatisticsByDay($this->request->all()));
    }
    #[PostMapping('getChatReplyStatistics'),ChPermission('ch:statistics:getChatReplyStatistics')]
    public function getChatReplyStatistics()
    {
        return $this->success($this->service->getChatReplyStatistics($this->request->all()));
    }
    #[PostMapping('getReplyStatisticsList'),ChPermission('ch:statistics:getReplyStatisticsList')]
    public function getReplyStatisticsList()
    {
        return $this->success($this->sopService->getReplyStatisticsList($this->request->all()));
    }

    #[PostMapping('getListenContactList'),ChPermission('ch:statistics:getListenContactList')]
    public function getListenContactList()
    {
        return $this->success($this->contactListenService->getListenContactList($this->request->all()));
    }

    #[PostMapping('delListenContact'),ChPermission('ch:statistics:delListenContact')]
    public function delListenContact()
    {
        return $this->contactListenService->deleteListen($this->request->all())? $this->success('操作成功') : $this->error('操作失败');
    }

    #[PostMapping('addListenContact'),ChPermission('ch:statistics:addListenContact')]
    public function addListenContact()
    {
        $result = $this->contactListenService->addListenContact($this->request->all());
        return $result? $this->success('操作成功') : $this->error('操作失败');
    }

    #[PostMapping('getListenContactByDay'),ChPermission('ch:statistics:getListenContactByDay')]
    public function getListenContactByDay()
    {
        $result = $this->contactListenService->getListenContactByDay($this->request->all());
        return $this->success($result);
    }
    #[PostMapping('getListenRoomByDay'),ChPermission('ch:statistics:getListenRoomByDay')]
    public function getListenRoomByDay()
    {
        $result = $this->roomListenService->getListenRoomByDay($this->request->all());
        return $this->success($result);
    }


    #[PostMapping('getListenRoomConfig'),ChPermission('ch:statistics:getListenRoomConfig')]
    public function getListenRoomConfig()
    {
        return $this->success($this->roomListenService->getConfig($this->request->all()));
    }


    #[PostMapping('getListenRoomLogList'),ChPermission('ch:statistics:getListenRoomLogList')]
    public function getListenRoomLogList()
    {
        return $this->success($this->roomListenService->getListenRoomLogList($this->request->all()));
    }

    #[PostMapping('getListenRoomList'),ChPermission('ch:statistics:getListenRoomList')]
    public function getListenRoomList()
    {
        return $this->success($this->roomListenService->getListenRoomList($this->request->all()));
    }

    #[PostMapping('delListenRoom'),ChPermission('ch:statistics:delListenRoom')]
    public function delListenRoom()
    {
        return $this->roomListenService->deleteListen($this->request->all())? $this->success('操作成功') : $this->error('操作失败');
    }

    #[PostMapping('addListenRoom'),ChPermission('ch:statistics:addListenRoom')]
    public function addListenRoom()
    {
        $result = $this->roomListenService->addListenRoom($this->request->all());
        return $result? $this->success('操作成功') : $this->error('操作失败');
    }


    #[PostMapping('calendar'),ChPermission('ch:statistics:calendar')]
    public function calendar()
    {
        $this->service->calendar($this->request->all());
    }

    #[PostMapping('getRoomStatistics'),ChPermission('ch:statistics:getRoomStatistics')]
    public function getRoomStatistics()
    {
        $result = $this->service->getRoomStatistics($this->request->all());
        return $this->success($result);
    }


    #[PostMapping('getCustomerStatistics'),ChPermission('ch:statistics:getCustomerStatistics')]
    public function getCustomerStatistics()
    {
        $result = $this->service->getCustomerStatistics($this->request->all());
        return $this->success($result);
    }

    #[PostMapping('customerStatisticsByDay'),ChPermission('ch:statistics:customerStatisticsByDay')]
    public function customerStatisticsByDay()
    {
        $result = $this->service->customerStatisticsByDay($this->request->all());
        return $this->success($result);
    }

    #[PostMapping('roomStatisticsByDay'),ChPermission('ch:statistics:customerStatisticsByDay')]
    public function roomStatisticsByDay()
    {
        $result = $this->service->roomStatisticsByDay($this->request->all());
        return $this->success($result);
    }

    #[PostMapping('lcStatisticsByDay'),ChPermission('ch:statistics:lcStatisticsByDay')]
    public function lcStatisticsByDay()
    {
        $result = $this->service->lcStatisticsByDay($this->request->all());
        return $this->success($result);
    }



}